import React, {Component} from 'react'
import { HashRouter as Router, Route, Switch, Redirect } from 'react-router-dom'
import Layout from '@/views/Layout'
import Login from '@/pages/login'
import {getUserInfo} from '@/utils/auth'

class Page extends Component {
    render(){
        return (
            <Router>
                <Switch>
                    <Route exact path="/" render={()=><Redirect to="/p" push/>}/>
                    <Route path="/p" component={Layout}/>
                    <Route path="/login" render={props=>{
                        if(getUserInfo()){
                            return <Redirect to="/p"/>
                        }else{
                            return <Login {...props}/>
                        }
                    }}/>
                </Switch>
            </Router>
        )
    }
}

export default Page


